package com.example.xungeng2.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.xungeng2.mapper.WorkerMapper;
import com.example.xungeng2.pojo.SendInfo;
import com.example.xungeng2.pojo.Worker;
import com.example.xungeng2.service.WorkerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class WorkerServiceImpl extends ServiceImpl<WorkerMapper, Worker> implements WorkerService {

    @Autowired
    private WorkerMapper workerMapper;

    @Override
    public Page<Worker> selectPage(long currentPage, long limit) {
        return baseMapper.selectPage(new Page<>(currentPage, limit),null);
    }

    @Override
    public boolean insert(Worker worker) {
        boolean save = this.save(worker);
        return save;
    }

    @Override
    public List<SendInfo> selectInfo(Integer userId) {
        List<SendInfo> sendInfoList = workerMapper.selectInfo(userId);
        return sendInfoList;
    }

    @Override
    public Integer findUserClock(Integer userId, String time) {
        Integer userClock = workerMapper.findUserClock(userId, time);
        return userClock;
    }

    @Override
    public List<String> findHistoryUserClock(Integer userId) {
        List<String> historyUserClock = workerMapper.findHistoryUserClock(userId);
        return historyUserClock;
    }

    @Override
    public void userClock(Integer userId, String time) {
        workerMapper.userClock(userId,time);
    }

    @Override
    public void addUserKQTJ(Integer userId, String realName, String time, String detailTime) {
        workerMapper.addUserKQTJ(userId,realName,time,detailTime);
    }

    @Override
    public void updateXGLXSign(Integer userId) {
        workerMapper.updateXGLXSign(userId);
    }

    @Override
    public int selectRWLCNumById(Integer userId) {
        return workerMapper.selectRWLCNumById(userId);
    }

    @Override
    public Integer selectUserToday(Integer userId, String format) {
        return workerMapper.selectUserToday(userId,format);
    }

    @Override
    public void updateUserKQTJ(Integer userId, int num) {
        workerMapper.updateUserKQTJ(userId, num);
    }

    @Override
    public void createUserTask(int parseInt) {
        workerMapper.createUserTask(parseInt);
    }


    @Override
    public void updateUserTaskNum(int userId) {
        workerMapper.updateUserTaskNum(userId);
    }
}